package com.kuang.demo02;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**线程池
 * @author FHL
 */
public class TestPool {
    public static void main(String[] args) {
MyThread myThread=new MyThread();
//创建服务，创建连接池
        //newFixedThreadPool参数:线程池多少个
        ExecutorService service = Executors.newFixedThreadPool(10);
        //执行
        service.execute(myThread);
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        //关闭连接
        service.shutdown();
    }
}
class MyThread implements Runnable{
    @Override
    public void run() {
        for (int i=0;i<100;i++){
            System.out.println(Thread.currentThread().getName()+i);
        }
    }
}
